<?php
/**
 * Subclass of flexible_table for mistajescollection report and download
 * @package   gradereport_mistakescollection
 * @author Jason <1129332567@qq.com>
 * @copyright  Jason (http://47.114.124.77)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 *
 */
require_once($CFG->libdir.'/tablelib.php');

class gradereport_mistakescollection_report_table extends flexible_table {
    public $course;
    public $extraheaders;
    var $download = '';
    var $downloadable = false;
    var $is_sortable    = true;
    var $column_nosort   = array('coursename','quziname','question','detail');
    var $sort_default_column = "number";
    var $sort_default_order  = SORT_DESC;

    public function __construct($course) {
        $this->course = $course;
        parent::__construct('grade_report_mistakescollection_report');
    }
    /**
    * Setup the columns and headers and other properties of the table and then
    * call flexible_table::setup() method.
    */
    public function setup($download = '') {
        global $CFG;
        // Define table columns
        $columns = array(
            'coursename',
            'quziname',
            'question',
            'number',
            'detail'
        );
        $headers=array (
            '课程名称',
            "测验名称",
            "试题",
            "答错次数",
            "详情"
        );
        $this->define_columns($columns);
        $this->define_headers($headers);
        $this->define_baseurl($CFG->wwwroot . '/grade/report/mistakescollection/report.php?id='.$this->course->id.'&tab=1');

        $this->set_attribute('cellspacing', '0');
        $this->set_attribute('id', 'mistakescollectionreport');
        $this->set_attribute('class', 'generaltable');
        $this->set_attribute('width', '100%');
        $this->set_attribute('align', 'center');

        parent::setup();
    }

    /**
     * Get the html for the download buttons
     * Usually only use internally
     */
    public function download_buttons() {
        return "";
    }
}